package com.wjerp.tplus.server.common.config;

import com.wjerp.tplus.server.common.security.PermissionActionMetaData;
import com.wjerp.tplus.server.domain.entity.sys.PermissionActionRelation;
import com.wjerp.tplus.server.domain.service.UserInfoService;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

import java.util.List;

/**
 * 系统启动时执行
 * @author lishuailei
 */
public class ApplicationStartup implements ApplicationListener<ContextRefreshedEvent> {
    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        UserInfoService userInfoService = contextRefreshedEvent.getApplicationContext().getBean(UserInfoService.class);
        
        List<PermissionActionRelation> permissionActionRelations = userInfoService.findAllPermissionActionRelation();
        PermissionActionMetaData.setMetaData(permissionActionRelations);

    }
}
